package com.lesama.domain;

import com.lesama.exception.ChineseScoreException;
import com.lesama.exception.EnglishScoreException;
import com.lesama.exception.MathScoreException;
import com.lesama.exception.StudentAgeException;

public class Student {
    private String name;
    private int age;
    private int math;
    private int chinese;
    private int english;

    public Student() {
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age){
        if(age >= 0 && age <= 120) {
            this.age = age;
        } else {
            throw new StudentAgeException("请输入一个0-120的整数年龄");
        }
    }

    public int getMath() {
        return math;
    }

    public void setMath(int math) {
        if(math >= 0 && math <= 150) {
            this.math = math;
        } else {
            throw new MathScoreException("请输入一个0-150的整数数学成绩");
        }
    }

    public int getChinese() {
        return chinese;
    }

    public void setChinese(int chinese) {
        if(chinese >= 0 && chinese <= 150) {
            this.chinese = chinese;
        } else {
            throw new ChineseScoreException("请输入一个0-150的整数语文成绩");
        }
    }

    public int getEnglish() {
        return english;
    }

    public void setEnglish(int english) {
        if(english >= 0 && english <= 150) {
            this.english = english;
        } else {
            throw new EnglishScoreException("请输入一个0-150的整数英语成绩");
        }
    }

    public Student(String name, int age) {
        this.name = name;
        setAge(age);
    }

    @Override
    public String toString() {
        return "Student{" + "name='" + name + '\'' + ", age=" + age + ", math=" + math + ", chinese=" + chinese
                + ", english=" + english + '}';
    }
}
